

package lc3vm;


public class Registros {

    private static int[] reg = new int[8];
    public static int ultimoR;
    

    public Registros(){
        for (int i = 0; i < 8; i++)
             reg[i] = 0;
    }

    public static void setR(int rNum, int rVal) {
        reg[rNum] = rVal;
        ultimoR = rNum;
    }

    public static int getR(int rNum) {
        return reg[rNum];
    }

    public static int getUltimoR() {
        return ultimoR;
    }

    public static String[][] getRegistros(){
        String[][] s = new String [8][2];

        for(int i = 0; i < 8; i++)
            for(int j = 0; j < 2; j++)
                if(j == 1)
                    s[i][j] = "" + reg[i];
                else
                    switch(i){
                        case 0: s[i][j] = "R0";
                        break;
                        case 1: s[i][j] = "R1";
                        break;
                        case 2: s[i][j] = "R2";
                        break;
                        case 3: s[i][j] = "R3";
                        break;
                        case 4: s[i][j] = "R4";
                        break;
                        case 5: s[i][j] = "R5";
                        break;
                        case 6: s[i][j] = "R5";
                        break;
                        case 7: s[i][j] = "R7";
                        break;
                    }
        return(s);
    }

}